package com.tomshushu.doc.freedoc.modular.projectuser.controller;

import com.tomshushu.doc.freedoc.core.model.response.ResponseData;
import com.tomshushu.doc.freedoc.core.model.response.SuccessResponseData;
import com.tomshushu.doc.freedoc.modular.projectuser.model.param.AddProjectUserParam;
import com.tomshushu.doc.freedoc.modular.projectuser.model.param.GetUserByProjectParam;
import com.tomshushu.doc.freedoc.modular.projectuser.model.param.UpdatePermissionPram;
import com.tomshushu.doc.freedoc.modular.projectuser.service.ProjectUserService;
import com.tomshushu.doc.freedoc.modular.teamuser.model.param.TeamUserParam;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author: zhouhong
 * @date: 2025-06-11 12:52
 * @version: 1.0
 */
@RestController
@RequestMapping("/doc/projectuser")
public class ProjectUserController {
    @Resource
    private ProjectUserService projectUserService;

    /**
     * 关联团队-用户
     * @param addProjectUserParam
     */
    @PostMapping("/addProjectUser")
    public ResponseData addProjectUser(@RequestBody AddProjectUserParam addProjectUserParam) {
        projectUserService.addProjectUser(addProjectUserParam);
        return new SuccessResponseData();
    }
    /**
     * 解除团队-用户关联
     * @param addProjectUserParam
     */
    @PostMapping("/deleteProjectUser")
    public ResponseData deleteProjectUser(@RequestBody AddProjectUserParam addProjectUserParam) {
        projectUserService.deleteProjectUser(addProjectUserParam);
        return new SuccessResponseData();
    }

    /**
     * 更新权限
     * @param pram
     */
    @PostMapping("/updatePermission")
    public ResponseData updatePermission(@RequestBody UpdatePermissionPram pram) {
        projectUserService.updatePermission(pram);
        return new SuccessResponseData();
    }

    /**
     * 获取项目下的用户
     * @param pram
     */
    @PostMapping("/getUserByProjectId")
    public ResponseData getUserByProjectId(@RequestBody GetUserByProjectParam pram) {
        return new SuccessResponseData(projectUserService.getUserByProjectId(pram));
    }


}